from rest_framework import serializers

from goods_app.models import ImageFile


class ImageSerializer(serializers.ModelSerializer):
    sku = serializers.CharField(source='f_sku', required=False)  # 反序列化时候不是必填项
    image = serializers.URLField(source='url', required=False)  # 反序列化时候不是必填项

    class Meta:
        fields = ['id', 'sku', 'image']
        model = ImageFile


